<script>
  var maximumGroups = function (grades) {
    grades.sort((a,b)=>a-b);
    const f = grades[0];
    let l = 1;
    let ans = 1;
    let n = grades.length-l;
    while(n>ans){
      ans++;
      l++;
      n-=l;
    }
    return ans;
  };
  console.log(maximumGroups([34,42,20,18,26,29,23,47,3,15,45,27,14,29,46,4,39,4,40,12,16,18,19,17,11,25,19,30,49,10,14,41,24,20,46,37,43,36,4,3,10,18,12,39,29]));
</script>